cmake_minimum_required(VERSION 3.5)

project(VideoDecoder VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 忽略代码中的中文注释引起的MSVC编译器警告
if(MSVC)
  add_compile_options(/source-charset:utf-8)
  add_compile_options(/execution-charset:utf-8)
endif()

# 创建收集所有源代码文件的函数
function(CollectSourceFiles current_dir variable)
  list(FIND ARGN "${current_dir}" IS_EXCLUDED)
  if(IS_EXCLUDED EQUAL -1)
    file(GLOB COLLECTED_SOURCES
      ${current_dir}/*.cpp
      ${current_dir}/*.h)
    list(APPEND ${variable} ${COLLECTED_SOURCES})

    file(GLOB SUB_DIRECTORIES ${current_dir}/*)
    foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
      if(IS_DIRECTORY ${SUB_DIRECTORY})
        CollectSourceFiles("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
      endif()
    endforeach()
    set(${variable} ${${variable}} PARENT_SCOPE)
  endif()
endfunction()

if(MSVC)
    find_package(FFMPEG REQUIRED)
    find_package(Poco REQUIRED COMPONENTS Foundation Net XML JSON Data DataMySQL Util)
endif()

include_directories(${FFMPEG_LIBRARY_DIRS})

include_directories(AFTER src)
add_subdirectory(src)